package com.itheima.stock.jobhandler;

import com.itheima.stock.service.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * author by itheima
 *
 * @Date 2022/1/15
 * Description
 */
@Component
public class StockJob {
    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @Autowired
    private StockTimerTaskService stockTimerTaskService;
    /**
     * 每周1到周5，上午九点半到11点半，下午1点到3点的流水数据
     * 定义每分钟获取一次国内大盘数据
     */
    @XxlJob("getStockAMarketTask")
    public void getStockAMarketTask(){
        stockTimerTaskService.getInnerMarketInfo();
    }
    /**
     * 获取股票实时数据
     */
    @XxlJob("getStockRtInfoTask")
    public void getStockRtInfoTask(){
        stockTimerTaskService.getStockRtIndex();
    }
    /**
     * 板块定时任务
     */
    @XxlJob("getStockBlockInfoTask")
    public void getStockBlockInfoTask(){
        stockTimerTaskService.getStockSectorIndex();
    }

    @XxlJob("heima-stock-job")
    public void jobTest(){
        System.out.println("jobTest run.....");
    }

    public void init(){
        logger.info("init");
    }

    public void destroy(){
        logger.info("destory");
    }
}
